package com.idea.zd.sys.train.thread;

import java.util.Date;

public class SleepThreadTest extends Thread{

    public SleepThreadTest(){
        super.setName("线程");
    }

    @Override
    public void run(){
        for(int i =0; i < 10000; i ++){
            System.out.println(getName()+":"+new Date()+" :"+i);
        }
    }

    public static void main(String [] args) throws InterruptedException {

        new SleepThreadTest().start();


        for(int i =0; i < 10; i ++){
            System.out.println(Thread.currentThread().getName()+":"+new Date()+" :"+i);

            if(i == 5){
                //当前线程睡眠3秒,线程进入阻塞，其它线程有机会执行
                Thread.sleep(3000);
            }
            System.out.println("醒来");
        }
    }
}
